package com.zhouwd.zplayer;

import android.content.Context;
import android.opengl.GLSurfaceView;
import android.os.Environment;

import java.io.File;

import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;

public class PreviewRender implements GLSurfaceView.Renderer {

    private Context mContext;
    private String filePath;
    private PreviewRenderNotify previewRenderNotify;
    public interface PreviewRenderNotify {
        void init();
    }

    public PreviewRender(Context mContext, String filePath, PreviewRenderNotify previewRenderNotify) {
        this.mContext = mContext;
        this.filePath = filePath;
        this.previewRenderNotify = previewRenderNotify;
    }

    @Override
    public void onSurfaceCreated(GL10 gl, EGLConfig config) {
        JniUtil.init(filePath, mContext.getAssets());
        if (previewRenderNotify != null) {
            previewRenderNotify.init();
        }
    }

    @Override
    public void onSurfaceChanged(GL10 gl, int width, int height) {
        JniUtil.resize();
    }

    @Override
    public void onDrawFrame(GL10 gl) {
        JniUtil.step();
    }

}
